<template>
    <div>
        <h3>Search Github Users</h3>
        <input type="text" v-model="keyword">
        <button @click="search">Search</button>
    </div>
</template>

<script>
export default {
    name: 'Search',
    data() {
        return {
            keyword: ''
        }
    },
    methods:{
        search() {
            this.$http.get(`https://api.github.com/search/users?q=${this.keyword}`)
            .then(
                response => {
                    console.log(response.data)
                    this.$bus.$emit('getUsers', response.data.items)
                }
            )
            .catch(
                error => {
                    console.log(error.message)
                }
            )
        }
    }
}
</script>

<style scoped>

</style>